unit Class_TOTL;

interface
uses
  Classes,SysUtils,Uni,UniEngine;

type
  TKJQJTOTL=class(TUniEngine)
  private
    FQUITKJQJ: Integer;
    FDOCTIDEX: Integer;
    FKJQJTOTL: Extended;
  protected
    procedure SetParameters;override;
    function  GetStrInsert:string;override;
    function  GetStrUpdate:string;override;
    function  GetStrDelete:string;override;
  public
    function  GetStrsIndex:string;override;
  public
    function  GetNextIdex:Integer;overload;
    function  GetNextIdex(AUniConnection:TUniConnection):Integer;overload;
  public
    function  CheckExist(AUniConnection:TUniConnection):Boolean;override;
  public
    destructor  Destroy; override;
    constructor Create;  
  published
    property QUITKJQJ: Integer read FQUITKJQJ write FQUITKJQJ;
    property DOCTIDEX: Integer read FDOCTIDEX write FDOCTIDEX;
    property KJQJTOTL: Extended read FKJQJTOTL write FKJQJTOTL;    
  public
    class function  ReadDS(AUniQuery:TUniQuery):TUniEngine;override;
    class procedure ReadDS(AUniQuery:TUniQuery;var Result:TUniEngine);override;
    class function  CopyIt(AKJQJTOTL:TKJQJTOTL):TKJQJTOTL;overload;        
    class procedure CopyIt(AKJQJTOTL:TKJQJTOTL;var Result:TKJQJTOTL);overload;       
  end;

implementation

{ TKJQJTOTL }
procedure TKJQJTOTL.SetParameters;
begin
  inherited;
  with FUniSQL.Params do
  begin
    case FOptTyp of
      otAddx:
      begin
        ParamByName('QUIT_KJQJ').Value := QUITKJQJ;
        ParamByName('DOCT_IDEX').Value := DOCTIDEX;
        ParamByName('KJQJ_TOTL').Value := KJQJTOTL; 
      end;
      otEdit:
      begin
        ParamByName('QUIT_KJQJ').Value := QUITKJQJ;
        ParamByName('DOCT_IDEX').Value := DOCTIDEX;
        ParamByName('KJQJ_TOTL').Value := KJQJTOTL; 
      end;  
      otDelt:
      begin
        ParamByName('QUIT_KJQJ').Value := QUITKJQJ;
        ParamByName('DOCT_IDEX').Value := DOCTIDEX;
        ParamByName('KJQJ_TOTL').Value := KJQJTOTL; 
      end;  
    end;
  end;
end;

function TKJQJTOTL.CheckExist(AUniConnection: TUniConnection): Boolean;
begin
  Result:=CheckExist('TBL_KJQJ_TOTL',['QUIT_KJQJ',QUITKJQJ,'DOCT_IDEX',DOCTIDEX,'KJQJ_TOTL',KJQJTOTL],AUniConnection);
end;

function TKJQJTOTL.GetNextIdex: Integer;
begin

end;

function TKJQJTOTL.GetNextIdex(AUniConnection: TUniConnection): Integer;
begin

end;

function TKJQJTOTL.GetStrDelete: string;
begin
  Result:='DELETE FROM TBL_KJQJ_TOTL WHERE   QUIT_KJQJ=:QUIT_KJQJ AND DOCT_IDEX=:DOCT_IDEX AND KJQJ_TOTL=:KJQJ_TOTL';
end;

function TKJQJTOTL.GetStrInsert: string;
begin
  Result:='INSERT INTO TBL_KJQJ_TOTL'
         +'    ( QUIT_KJQJ, DOCT_IDEX, KJQJ_TOTL)'
         +'    VALUES'
         +'    (:QUIT_KJQJ,:DOCT_IDEX,:KJQJ_TOTL)';
end;

function TKJQJTOTL.GetStrsIndex: string;
begin
  Result:=Format('%D-%D',[QUITKJQJ,DOCTIDEX]);
end;

function TKJQJTOTL.GetStrUpdate: string;
begin
  raise Exception.Create('CAN NOT SUPPORT GETSTRUPDATE METHOD.CAUSE ALL THIS TABLE FILEDS ARE PRIMARY KEY.')
end;

constructor TKJQJTOTL.Create;
begin

end;

destructor TKJQJTOTL.Destroy;
begin

  inherited;
end;

class function TKJQJTOTL.ReadDS(AUniQuery: TUniQuery): TUniEngine;
begin
  Result:=TKJQJTOTL.Create;
  with TKJQJTOTL(Result) do
  begin
    QUITKJQJ:=AUniQuery.FieldByName('QUIT_KJQJ').AsInteger;
    DOCTIDEX:=AUniQuery.FieldByName('DOCT_IDEX').AsInteger;
    KJQJTOTL:=AUniQuery.FieldByName('KJQJ_TOTL').AsFloat;
  end;  
end;

class procedure TKJQJTOTL.ReadDS(AUniQuery: TUniQuery; var Result: TUniEngine);
begin
  if Result=nil then Exit;
  with TKJQJTOTL(Result) do
  begin
    QUITKJQJ:=AUniQuery.FieldByName('QUIT_KJQJ').AsInteger;
    DOCTIDEX:=AUniQuery.FieldByName('DOCT_IDEX').AsInteger;
    KJQJTOTL:=AUniQuery.FieldByName('KJQJ_TOTL').AsFloat;
  end;  
end;

class function  TKJQJTOTL.CopyIt(AKJQJTOTL: TKJQJTOTL): TKJQJTOTL;
begin
  Result:=TKJQJTOTL.Create;
  TKJQJTOTL.CopyIt(AKJQJTOTL,Result)
end;

class procedure TKJQJTOTL.CopyIt(AKJQJTOTL:TKJQJTOTL;var Result:TKJQJTOTL);
begin
  if Result=nil then Exit;
  Result.QUITKJQJ:=AKJQJTOTL.QUITKJQJ;
  Result.DOCTIDEX:=AKJQJTOTL.DOCTIDEX;
  Result.KJQJTOTL:=AKJQJTOTL.KJQJTOTL;
end;

end.

